# 作者：凡梓辰

def is_num(c):

    if (ord(c) >= ord('0') and ord(c) <= ord('9')):
        return True
    else:
        return False


def check(c):

    if (is_num(c) == False and c != '.' and c != '//' and c != '^' and c != ' ' and c != '+' and c != '-' and c != '*' and c != '/' and c != '%'):
        return True
    else:
        return False


# 如果不需要无限循环可以把这句删掉，然后把下面每行前删除一个缩进
while True:
    s_first = ''
    s_last = ''
    fl = True
    is_ok = True
    fu = ''
    s = input('请输入运算式：')
    i = 0
    size = len(s)
    for c in s:
        if check(c):
            is_ok = False
    if (is_ok == False):
        print('输入非法，请检查输入！')
    else:
        while (i < size):
            c = s[i]
            if (c != ' '):
                if (is_num(c) and fl):
                    s_first = (s_first + c)
                elif (is_num(c) and fl == False):
                    s_last = (s_last + c)
                elif (c == '.' and fl):
                    s_first = (s_first + '.')
                elif (c == '.' and fl == False):
                    s_last = (s_last + '.')
                else:
                    fu = c
                    fl = False
            i = (i + 1)
        first = float(s_first)
        last = float(s_last)
        if (fu == '+'):
            print("The answer is :", first + last)
        elif (fu == '-'):
            print("The answer is :", first - last)
        elif (fu == '*'):
            print("The answer is :", first * last)
        elif (fu == '/'):
            print("The answer is :", first / last)
        elif (fu == '//'):
            print("The answer is :", first // last)
        elif fu == '%':
            print("The answer is :", first % last)
        elif (fu == '^'):
            if (last % 1 != 0):
                print("运算中第二个数字只可为整数！")
            else:
                print("The answer is :", first ** int(last))
